from os.path import join, abspath
from typing import List
from backend.experiment.framework.implement import PromptPerplexityImplement


class CLUEOscarTextPerplexityImplement(PromptPerplexityImplement):
    @classmethod
    def get_test_sample_prompt(cls) -> List[str]:
        with open(join(cls.data_dir(), 'clue_oscar_20000.txt'), 'r',
                  encoding='utf8') as file:
            records = []
            for each in file.readlines():
                each = each.strip()
                if len(each) < 1000:
                    records.append(each)
        return records

    @classmethod
    def data_dir(cls) -> str:
        return abspath(join(__file__, '../'))

    @classmethod
    def cache_dir(cls) -> str:
        return join(cls.work_dir(), 'cache')

    @classmethod
    def work_dir(cls) -> str:
        return abspath(join(__file__, '..'))
